package com.gluxen.entity;

import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.gluxen.common.constant.SystemConstant;
import com.gluxen.entity.BaseEntity;

/**
 *用户实体表
 *已实现org.jbpm.api.identity.User接口，与JBPM公用用户对象
 */
@Entity
@Table(name = "USER")
public class User extends BaseEntity{
	private static final long serialVersionUID = 487092737452798527L;

	/** 用户主键 */
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "PK_USER_ID")
	private Integer id;

	/** 昵称 */
	@Column(name = "NICKNAME", length = 100)
	private String nickname;
	
	/** 所属网点  401金牛支行营业室（沙湾路）
				402成都花园支行（青羊大道）
				403荷花池支行（金牛万达旁） 
				404外西支行（花牌坊北街）
				405天回支行（天回镇上街）
				406高笋塘支行（二环路北三段）
				407西郊支行（十二桥路）
				408洞子口支行（洞子口）
				409蜀鑫支行（蜀鑫路）
				410蜀西支行（蜀西路）
				411五福支行（蓉北商贸大道）
				412茶店子支行（茶店子东街）
				413国际商贸城支行（国际商贸城）
				414光华逸家分理处（万家湾光华逸家小区）
				415大湾分理处（军区总医院内）
				416蜀汉路支行（蜀蓉路）
				417星辰支行（九里堤星辰路）*/ 
	@Column(name = "DOT",nullable = true)
	@NotNull(message="所属网点不能为空！")
	private Integer dot;
	

	/** 真实姓名 */
	@Column(name = "REAL_NAME", length = 50, nullable = true)
	
	private String realname;

	/** 手机号码 */
	@Column(name = "TEL", length = 20, nullable = true)
	private String tel;

	
	/** 密码 */
	@Column(name = "PASSWORD", length = 50)
	//@Size(min=5,max=16,message="密码长度为5到16位")
	private String password;
	
	/**用户所属客户经理 */
	@Column(name = "MANAGER", length = 50)
	private Integer manager;
	
	/** 性别 0 男 1 女*/
	@Column(name = "GENDER", length = 2)
	private Integer gender;

	/** 出生日期 */
	@Temporal(TemporalType.DATE)
	@Column(name = "BIRTH")
	@DateTimeFormat(pattern=SystemConstant.DATE_PATTEN)
	private Date birth;
	
	/**注册日期*/
	@Column(name = "REG_DATE")
	@DateTimeFormat(pattern=SystemConstant.TIME_PATTEN)
	private Date regDate;
	
	/**发送短信的日期时间*/
	@Column(name = "SEND_MESSAGE_DATE")
	@DateTimeFormat(pattern=SystemConstant.TIME_PATTEN)
	private Date sendMessageDate;
	
    /** 积分*/
	@Column(name = "INTEGRATION", length = 10)
	private Integer Integration=0;
	
	/**微信标识*/
	@Column(name = "OPENID", length = 50)
	private String openID;
	
	/**用户身份*/
	@Column(name = "Job", length = 20)
	private String Job;
	
	/** 上次签到日期 */
	@Column(name = "SIGN_IN")
	@DateTimeFormat(pattern=SystemConstant.DATE_PATTEN)
	private Date SignIn;

	@Transient @JsonIgnore
	private Set<Integer> privs;	// 权限表
	
	@Transient @JsonIgnore
	private Set<Integer> roles;	// 权限表
	
	public Set<Integer> getPrivs() {
		return privs;
	}

	public void setPrivs(Set<Integer> privs) {
		this.privs = privs;
	}
	public Date getSignIn() {
		return SignIn;
	}

	public void setSignIn(Date signIn) {
		this.SignIn = signIn;
	}
	public Set<Integer> getRoles() {
		return roles;
	}

	public void setRoles(Set<Integer> roles) {
		this.roles = roles;
	}
	public Date getBirth() {
		return birth;
	}

	public void setBirth(Date birth) {
		this.birth = birth;
	}

	public Date getRegDate() {
		return regDate;
	}

	public void setRegDate(Date regDate) {
		this.regDate = regDate;
	}

	public String getJob() {
		return Job;
	}

	public void setJob(String job) {
		Job = job;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Integer getGender() {
		return gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}

	public Integer getIntegration() {
		return Integration;
	}

	public void setIntegration(Integer integration) {
		Integration = integration;
	}

	public String getOpenID() {
		return openID;
	}

	public void setOpenID(String openID) {
		this.openID = openID;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public boolean equals(Object user) {
		return user instanceof User && ((User)user).getId().equals(getId());
	}

	public Integer getManager() {
		return manager;
	}

	public void setManager(Integer manager) {
		this.manager = manager;
	}
	
	public Integer getDot() {
		return dot;
	}

	public void setDot(Integer dot) {
		this.dot = dot;
	}

	public Date getSendMessageDate() {
		return sendMessageDate;
	}

	public void setSendMessageDate(Date sendMessageDate) {
		this.sendMessageDate = sendMessageDate;
	}
	
}
